package com.hnkywl.jip.service;

import com.hnkywl.jip.dao.BasicDao;
import com.hnkywl.jip.dao.CompanyDao;
import com.hnkywl.jip.dao.SupplierDao;
import net.ruixin.orm.hibernate.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


/**
 * 说明：
 * 包:        com.hnkywl.jip.service
 * 类描述:    [一句话描述该类的功能]
 * 创建人:    ZHUCHG
 * 创建时间: 13-2-28 下午8:59
 * 修改人:    ZHUCHG
 * 修改时间: 13-2-28 下午8:59
 * 修改备注: [说明本次修改内容]
 * 版本:        [v1.0]
 */
@Service
public class SupplierService {
    private SupplierDao supplierDao;
    private CompanyDao companyDao;

    @Transactional
    public Page<Object[]> findSupplier(Integer companyId, Integer supplierId, String code, Integer limit, Integer start) {
        return supplierDao.findSupplier(companyId, supplierId, code, limit, start);
    }

    @Transactional
    public List findCompany() {
        return companyDao.searchAllCompany();
    }

    @Transactional
    public void saveSupplierMapping(Integer companyId, Integer supplierId, String code) {
        supplierDao.deleteSupplierMapping(companyId, supplierId);
        supplierDao.saveSupplierMapping(companyId, supplierId, code);
    }

    @Autowired
    public void setSupplierDao(SupplierDao supplierDao) {
        this.supplierDao = supplierDao;
    }

    @Autowired
    public void setCompanyDao(CompanyDao companyDao) {
        this.companyDao = companyDao;
    }
}
